package com.example.test.api;

import com.example.test.User;
import com.example.test.UserAddress;
import com.example.test.contract.CreateUserAddressParams;
import com.example.test.contract.QueryUserParams;
import com.example.test.suppert.base.result.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * Created by lsl on 2021/2/24.
 */
@Api(tags = "User测试接口")
@RestController
@RequestMapping("user")
public interface UserRest {

    @GetMapping(value = "test")
    @ApiOperation("测试接口")
    BaseResult<String> test();

    @GetMapping("create")
    @ApiOperation(value = "创建用户")
    boolean create(String name);

    @GetMapping("all")
    @ApiOperation("查询所有用户")
    BaseResult<String> queryAllUser();

    @GetMapping(value = "query", produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "根据条件查询用户")
    @ResponseBody
    BaseResult<List<User>> queryUser(@Valid QueryUserParams user);

    @GetMapping("query/_id")
    @ApiOperation("根据id查询用户")
    User queryUserById(@RequestParam(value = "id") Long id);

    @GetMapping("create/address")
    @ApiOperation(value = "新增用户地址")
    BaseResult<UserAddress> createUserAddress(@Validated CreateUserAddressParams params);
}
